'''
字典
'''
dict1 = {'abf': 16, '喜爱新': 'sdadasd', 3: {'name': 'lisi'}}
print(dict1['abf'])

person = {'name': 'xiaom', 'age': 20, 'tel': '1502231613'}
print(person['tel'])
print(person.get('name'))
print(person.keys())
print(person.values())
print(person.items())
person['name'] = 'xiaosan'
print(person)
person['addr'] = 'chengdu'
print(person)
del person['tel']
print(person)
r = person.pop('name')
print(r)
print(person)

print('--------------------------')
# 练习：
all_stu = [
    {'name': 'xiaom', 'age': 28, 'score': 90, 'tel': '18231213'},
    {'name': 'dah', 'age': 16, 'score': 23, 'tel': '18231213'},
    {'name': 'tom', 'age': 21, 'score': 78, 'tel': '18231213'},
    {'name': 'xiaoh', 'age': 17, 'score': 98, 'tel': '18231213'},
    {'name': 'ahuang', 'age': 30, 'score': 76, 'tel': '18231213'}
]
# 统计以上学生中不及格学生人数
nums = 0
for stu in all_stu:
    if stu['score'] < 60:
        nums += 1
print(nums)
# 打印所有未成年学生姓名
for stu in all_stu:
    if stu['age'] < 18:
        print(stu['name'])
# 将年龄为25以上的学生电话设置为保密
for stu in all_stu:
    if stu['age'] > 25:
        stu['tel'] = '保密'
print(all_stu)
